/**
 * @file main.c
 * @brief 
 * @author Dream Shao (1090820065@qq.com)
 * @version 1.0
 * @date 2025-07-12
 * 
 * @copyright Copyright (c) 2025
 * 
 * @par 修改日志:
 * Date       Version    Author       Description
 * 2025-07-12     1.0        
 */
#include "gd32f4xx_misc.h"

#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "timers.h"
#include "semphr.h"
#include "logging_stack.h"

#include "led.h"
#include "board_cfg.h"
#include "fml_log.h"

/*******************************************************************************
 * Definitions
 ******************************************************************************/

/*******************************************************************************
 * Variables
 ******************************************************************************/
void AppTaskCreate(void);
static TaskHandle_t     AppTaskCreate_Handle = NULL;

char Log_test[] = "Hello, world!\r\n";
 /******************************************************************************
 * Code
 ******************************************************************************/
/**
 * @brief 主函数，用于外设初始化和线程启动
 * @return int 
 */
int main(void)
{ 
    BaseType_t xReturn = pdPASS;
    
    nvic_priority_group_set(NVIC_PRIGROUP_PRE4_SUB0);
    vBoard_ClockInit();
    SEGGER_RTT_Init();
	led_init();
    vFml_Log_Init();
	
    xReturn = xTaskCreate((TaskFunction_t )AppTaskCreate,
                        (const char*   )"App_Task",
                        (uint16_t       )256,
                        (void*         )NULL,
                        (UBaseType_t    )1, 
                        (TaskHandle_t*  )&AppTaskCreate_Handle);
    if(pdPASS == xReturn)
    {
        LogInfo("App Task Create Success\r\n");
    }else
    {
        LogError("App Task Create Fail\r\n");
    }

    if(pdPASS == xReturn)
        vTaskStartScheduler();
    while(1);
}
/**
 * @brief LED灯
 */
void AppTaskCreate(void){
	while(1)
	{
        vFml_Log_Print(Log_test);
        LED0(1);                            /* LED0亮 */
        LED1(1);                            /* LED1灭 */ 
        vTaskDelay(1000);
        LED0(0);                            /* LED0灭 */
        LED1(0);                            /* LED1亮 */ 
        vTaskDelay(1000);
	}
}
